#include <stdio.h>

#include "../inc/touch.h"
#include "../inc/dlist.h"
#include "../inc/lcd.h"
#include "../inc/bmp.h"
#include "../inc/dir.h"
#include "../inc/registerLogin.h"
#include "../inc/my_arithmetic.h"
#include "../inc/main_interface.h"
#include "../inc/my_thread.h"



int main(){
    //初始化液晶屏
    lcd_init();
    //打开触摸屏
    open_touch();
    //进入系统时的界面
    bmp_show("./res/interface/into_project.bmp",0,0);
    bmp_show_small("./res/interface/logo.bmp",0,0);
    time_prograss_bar();
    //进入系统
    //进入登陆注册界面
        //创建头节点链表
    DNode_t* user_head = list_init();
        //读取用户信息并写入链表中
    readFromFileAndAddToList(user_head);
    //创建 一个变量 ，表明是<他>登陆完成在使用这个系统
    char user_use_sys[MAX_ACCOUNT] = {0};
    int select_mode;
    int loginsuccess = 0; //===预判一下在主界面返回，这个要置为0===
    int select_main;
    while(1){
        //登陆注册界面操作判断
        if(loginsuccess == 0){
            select_mode = while_log_reg_exit(user_head ,user_use_sys);
            if(select_mode == LOGIN_BUTTON){
                //登陆成功
                loginsuccess = 1;
            }
            if(select_mode == RL_EXIT_BUTTON){
                return 0;
            }
        }
        //主界面操作判断
        if(loginsuccess == 1){
            printf("%s用户进入主界面\n",user_use_sys);
            select_main = while_main_touch(user_use_sys);
            if(select_main == MAIN_EXIT_BUTTON){
                loginsuccess = 0;
            }
            
        }
    }

    //关闭触摸屏
    close_touch();
    lcd_destory();
    return 0;
}